<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
  Module: Mocha::ParameterMatchers::Methods
  
    &mdash; Mocha 3.0.0-rc.2
  
</title>

  <link rel="stylesheet" href="../../css/style.css" type="text/css" />

  <link rel="stylesheet" href="../../css/common.css" type="text/css" />

<script type="text/javascript">
  pathId = "Mocha::ParameterMatchers::Methods";
  relpath = '../../';
</script>


  <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>

  <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>


  </head>
  <body>
    <div class="nav_wrap">
      <iframe id="nav" src="../../class_list.html?1"></iframe>
      <div id="resizer"></div>
    </div>

    <div id="main" tabindex="-1">
      <div id="header">
        <div id="menu">
  
    <a href="../../_index.html">Index (M)</a> &raquo;
    <span class='title'><span class='object_link'><a href="../../Mocha.html" title="Mocha (module)">Mocha</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../ParameterMatchers.html" title="Mocha::ParameterMatchers (module)">ParameterMatchers</a></span></span>
     &raquo; 
    <span class="title">Methods</span>
  
</div>

        <div id="search">
  
    <a class="full_list_link" id="class_list_link"
        href="../../class_list.html">

        <svg width="24" height="24">
          <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
          <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
          <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
        </svg>
    </a>
  
</div>
        <div class="clear"></div>
      </div>

      <div id="content"><h1>Module: Mocha::ParameterMatchers::Methods
  
  
  
</h1>
<div class="box_info">
  

  
  
  
  
  

  
  <dl>
    <dt>Included in:</dt>
    <dd><span class='object_link'><a href="../API.html" title="Mocha::API (module)">API</a></span></dd>
  </dl>
  

  
  <dl>
    <dt>Defined in:</dt>
    <dd>lib/mocha/parameter_matchers.rb<span class="defines">,<br />
  lib/mocha/parameter_matchers/not.rb,<br /> lib/mocha/parameter_matchers/is_a.rb,<br /> lib/mocha/parameter_matchers/all_of.rb,<br /> lib/mocha/parameter_matchers/any_of.rb,<br /> lib/mocha/parameter_matchers/equals.rb,<br /> lib/mocha/parameter_matchers/has_key.rb,<br /> lib/mocha/parameter_matchers/kind_of.rb,<br /> lib/mocha/parameter_matchers/anything.rb,<br /> lib/mocha/parameter_matchers/has_keys.rb,<br /> lib/mocha/parameter_matchers/includes.rb,<br /> lib/mocha/parameter_matchers/has_entry.rb,<br /> lib/mocha/parameter_matchers/has_value.rb,<br /> lib/mocha/parameter_matchers/optionally.rb,<br /> lib/mocha/parameter_matchers/has_entries.rb,<br /> lib/mocha/parameter_matchers/instance_of.rb,<br /> lib/mocha/parameter_matchers/responds_with.rb,<br /> lib/mocha/parameter_matchers/any_parameters.rb,<br /> lib/mocha/parameter_matchers/equivalent_uri.rb,<br /> lib/mocha/parameter_matchers/regexp_matches.rb,<br /> lib/mocha/parameter_matchers/yaml_equivalent.rb</span>
</dd>
  </dl>
  
</div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    
<p>These methods build instances of the <span class='object_link'><a href="../ParameterMatchers.html" title="Mocha::ParameterMatchers (module)">Mocha::ParameterMatchers</a></span> classes which are used with <span class='object_link'><a href="../Expectation.html#with-instance_method" title="Mocha::Expectation#with (method)">Expectation#with</a></span> to restrict the parameter values. Can be nested, e.g. see <span class='object_link'><a href="#all_of-instance_method" title="Mocha::ParameterMatchers::Methods#all_of (method)">#all_of</a></span> examples.</p>


  </div>
</div>
<div class="tags">
  

</div>






  
    <h2>
      Instance Method Summary
      <small><a href="#" class="summary_toggle">collapse</a></small>
    </h2>

    <ul class="summary">
      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#all_of-instance_method" title="#all_of (instance method)">#<strong>all_of</strong>(*matchers)  &#x21d2; AllOf </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>
<p>Matches if all <code>matchers</code> match.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#any_of-instance_method" title="#any_of (instance method)">#<strong>any_of</strong>(*matchers)  &#x21d2; AnyOf </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>
<p>Matches if any <code>matchers</code> match.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#any_parameters-instance_method" title="#any_parameters (instance method)">#<strong>any_parameters</strong>  &#x21d2; AnyParameters </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>
<p>Matches any parameters.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#anything-instance_method" title="#anything (instance method)">#<strong>anything</strong>  &#x21d2; Anything </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>
<p>Matches any object.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#equals-instance_method" title="#equals (instance method)">#<strong>equals</strong>(value)  &#x21d2; Equals </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>
<p>Matches any <code>Object</code> equalling <code>value</code>.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#equivalent_uri-instance_method" title="#equivalent_uri (instance method)">#<strong>equivalent_uri</strong>(uri)  &#x21d2; EquivalentUri </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>
<p>Matches a URI without regard to the ordering of parameters in the query string.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#has_entries-instance_method" title="#has_entries (instance method)">#<strong>has_entries</strong>(entries)  &#x21d2; HasEntries </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>
<p>Matches <code>Hash</code> containing all <code>entries</code>.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#has_entry-instance_method" title="#has_entry (instance method)">#<strong>has_entry</strong>(*options)  &#x21d2; HasEntry </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>
<p>Matches <code>Hash</code> containing entry with <code>key</code> and <code>value</code>.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#has_key-instance_method" title="#has_key (instance method)">#<strong>has_key</strong>(key)  &#x21d2; HasKey </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>
<p>Matches <code>Hash</code> containing <code>key</code>.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#has_keys-instance_method" title="#has_keys (instance method)">#<strong>has_keys</strong>(*keys)  &#x21d2; HasKeys </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>
<p>Matches <code>Hash</code> containing <code>keys</code>.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#has_value-instance_method" title="#has_value (instance method)">#<strong>has_value</strong>(value)  &#x21d2; HasValue </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>
<p>Matches <code>Hash</code> containing <code>value</code>.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#includes-instance_method" title="#includes (instance method)">#<strong>includes</strong>(*items)  &#x21d2; Includes </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>
<p>Matches any object that responds with <code>true</code> to <tt>include?(item)</tt> for all items.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#instance_of-instance_method" title="#instance_of (instance method)">#<strong>instance_of</strong>(klass)  &#x21d2; InstanceOf </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>
<p>Matches any object that is an instance of <code>klass</code>.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#is_a-instance_method" title="#is_a (instance method)">#<strong>is_a</strong>(klass)  &#x21d2; IsA </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>
<p>Matches any object that is a <code>klass</code>.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#kind_of-instance_method" title="#kind_of (instance method)">#<strong>kind_of</strong>(klass)  &#x21d2; KindOf </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>
<p>Matches any <code>Object</code> that is a kind of <code>klass</code>.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#Not-instance_method" title="#Not (instance method)">#<strong>Not</strong>(matcher)  &#x21d2; Not </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>
<p>Matches if <code>matcher</code> does <strong>not</strong> match.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#optionally-instance_method" title="#optionally (instance method)">#<strong>optionally</strong>(*matchers)  &#x21d2; Optionally </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>
<p>Matches optional parameters if available.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#regexp_matches-instance_method" title="#regexp_matches (instance method)">#<strong>regexp_matches</strong>(regexp)  &#x21d2; RegexpMatches </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>
<p>Matches any object that matches <code>regexp</code>.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#responds_with-instance_method" title="#responds_with (instance method)">#<strong>responds_with</strong>(*options)  &#x21d2; RespondsWith </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>
<p>Parameter matcher.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#yaml_equivalent-instance_method" title="#yaml_equivalent (instance method)">#<strong>yaml_equivalent</strong>(object)  &#x21d2; YamlEquivalent </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>
<p>Matches any YAML that represents the specified <code>object</code>.</p>
</div></span>
  
</li>

      
    </ul>
  



  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>

    
      <div class="method_details first">
  <h3 class="signature first" id="all_of-instance_method">
  
    #<strong>all_of</strong>(*matchers)  &#x21d2; <tt><span class='object_link'><a href="AllOf.html" title="Mocha::ParameterMatchers::AllOf (class)">AllOf</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    
<p>Matches if all <code>matchers</code> match.</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h4 class="tag_title">Examples:</h4>
    
      
        <h5 class="example_title"><div class='inline'>
<p>All parameter matchers match.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_all_of'>all_of</span><span class='lparen'>(</span><span class='id identifier rubyid_includes'>includes</span><span class='lparen'>(</span><span class='int'>1</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_includes'>includes</span><span class='lparen'>(</span><span class='int'>3</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='int'>1</span><span class='comma'>,</span> <span class='int'>3</span><span class='rbracket'>]</span><span class='rparen'>)</span>
<span class='comment'># no error raised</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>One of the parameter matchers does not match.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_all_of'>all_of</span><span class='lparen'>(</span><span class='id identifier rubyid_includes'>includes</span><span class='lparen'>(</span><span class='int'>1</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_includes'>includes</span><span class='lparen'>(</span><span class='int'>3</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='int'>1</span><span class='comma'>,</span> <span class='int'>2</span><span class='rbracket'>]</span><span class='rparen'>)</span>
<span class='comment'># error raised, because method_1 was not called with object including 1 and 3</span></code></pre>
    
  </div>
<p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>matchers</span>
      
      
        <span class='type'>(<tt>*Array&lt;<span class='object_link'><a href="BaseMethods.html" title="Mocha::ParameterMatchers::BaseMethods (module)">BaseMethods</a></span>&gt;</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>parameter matchers.</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="AllOf.html" title="Mocha::ParameterMatchers::AllOf (class)">AllOf</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>parameter matcher.</p>
</div>
      
    </li>
  
</ul>

  <p class="tag_title">See Also:</p>
  <ul class="see">
    
      <li><span class='object_link'><a href="../Expectation.html#with-instance_method" title="Mocha::Expectation#with (method)">Expectation#with</a></span></li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


26
27
28</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/mocha/parameter_matchers/all_of.rb', line 26</span>

<span class='kw'>def</span> <span class='id identifier rubyid_all_of'>all_of</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_matchers'>matchers</span><span class='rparen'>)</span>
  <span class='const'><span class='object_link'><a href="AllOf.html" title="Mocha::ParameterMatchers::AllOf (class)">AllOf</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_matchers'>matchers</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="any_of-instance_method">
  
    #<strong>any_of</strong>(*matchers)  &#x21d2; <tt><span class='object_link'><a href="AnyOf.html" title="Mocha::ParameterMatchers::AnyOf (class)">AnyOf</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    
<p>Matches if any <code>matchers</code> match.</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h4 class="tag_title">Examples:</h4>
    
      
        <h5 class="example_title"><div class='inline'>
<p>One parameter matcher matches.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_any_of'>any_of</span><span class='lparen'>(</span><span class='int'>1</span><span class='comma'>,</span> <span class='int'>3</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='int'>1</span><span class='rparen'>)</span>
<span class='comment'># no error raised</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>The other parameter matcher matches.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_any_of'>any_of</span><span class='lparen'>(</span><span class='int'>1</span><span class='comma'>,</span> <span class='int'>3</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='int'>3</span><span class='rparen'>)</span>
<span class='comment'># no error raised</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Neither parameter matcher matches.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_any_of'>any_of</span><span class='lparen'>(</span><span class='int'>1</span><span class='comma'>,</span> <span class='int'>3</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='int'>2</span><span class='rparen'>)</span>
<span class='comment'># error raised, because method_1 was not called with 1 or 3</span></code></pre>
    
  </div>
<p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>matchers</span>
      
      
        <span class='type'>(<tt>*Array&lt;<span class='object_link'><a href="BaseMethods.html" title="Mocha::ParameterMatchers::BaseMethods (module)">BaseMethods</a></span>&gt;</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>parameter matchers.</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="AnyOf.html" title="Mocha::ParameterMatchers::AnyOf (class)">AnyOf</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>parameter matcher.</p>
</div>
      
    </li>
  
</ul>

  <p class="tag_title">See Also:</p>
  <ul class="see">
    
      <li><span class='object_link'><a href="../Expectation.html#with-instance_method" title="Mocha::Expectation#with (method)">Expectation#with</a></span></li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


32
33
34</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/mocha/parameter_matchers/any_of.rb', line 32</span>

<span class='kw'>def</span> <span class='id identifier rubyid_any_of'>any_of</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_matchers'>matchers</span><span class='rparen'>)</span>
  <span class='const'><span class='object_link'><a href="AnyOf.html" title="Mocha::ParameterMatchers::AnyOf (class)">AnyOf</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_matchers'>matchers</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="any_parameters-instance_method">
  
    #<strong>any_parameters</strong>  &#x21d2; <tt><span class='object_link'><a href="AnyParameters.html" title="Mocha::ParameterMatchers::AnyParameters (class)">AnyParameters</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    
<p>Matches any parameters. This is used as the default for a newly built expectation.</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h4 class="tag_title">Examples:</h4>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Any parameters will match.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_any_parameters'>any_parameters</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='int'>1</span><span class='comma'>,</span> <span class='int'>2</span><span class='comma'>,</span> <span class='int'>3</span><span class='comma'>,</span> <span class='int'>4</span><span class='rparen'>)</span>
<span class='comment'># no error raised
</span>
<span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_any_parameters'>any_parameters</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='int'>5</span><span class='comma'>,</span> <span class='int'>6</span><span class='comma'>,</span> <span class='int'>7</span><span class='comma'>,</span> <span class='int'>8</span><span class='comma'>,</span> <span class='int'>9</span><span class='comma'>,</span> <span class='int'>0</span><span class='rparen'>)</span>
<span class='comment'># no error raised</span></code></pre>
    
  </div>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="AnyParameters.html" title="Mocha::ParameterMatchers::AnyParameters (class)">AnyParameters</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>parameter matcher.</p>
</div>
      
    </li>
  
</ul>

  <p class="tag_title">See Also:</p>
  <ul class="see">
    
      <li><span class='object_link'><a href="../Expectation.html#with-instance_method" title="Mocha::Expectation#with (method)">Expectation#with</a></span></li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


24
25
26</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/mocha/parameter_matchers/any_parameters.rb', line 24</span>

<span class='kw'>def</span> <span class='id identifier rubyid_any_parameters'>any_parameters</span>
  <span class='const'><span class='object_link'><a href="AnyParameters.html" title="Mocha::ParameterMatchers::AnyParameters (class)">AnyParameters</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="anything-instance_method">
  
    #<strong>anything</strong>  &#x21d2; <tt><span class='object_link'><a href="Anything.html" title="Mocha::ParameterMatchers::Anything (class)">Anything</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    
<p>Matches any object.</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h4 class="tag_title">Examples:</h4>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Any object will match.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_anything'>anything</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>foo</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='int'>789</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='symbol'>:bar</span><span class='rparen'>)</span>
<span class='comment'># no error raised</span></code></pre>
    
  </div>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="Anything.html" title="Mocha::ParameterMatchers::Anything (class)">Anything</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>parameter matcher.</p>
</div>
      
    </li>
  
</ul>

  <p class="tag_title">See Also:</p>
  <ul class="see">
    
      <li><span class='object_link'><a href="../Expectation.html#with-instance_method" title="Mocha::Expectation#with (method)">Expectation#with</a></span></li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


21
22
23</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/mocha/parameter_matchers/anything.rb', line 21</span>

<span class='kw'>def</span> <span class='id identifier rubyid_anything'>anything</span>
  <span class='const'><span class='object_link'><a href="Anything.html" title="Mocha::ParameterMatchers::Anything (class)">Anything</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="equals-instance_method">
  
    #<strong>equals</strong>(value)  &#x21d2; <tt><span class='object_link'><a href="Equals.html" title="Mocha::ParameterMatchers::Equals (class)">Equals</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    
<p>Matches any <code>Object</code> equalling <code>value</code>.</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h4 class="tag_title">Examples:</h4>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter equals expected parameter.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_equals'>equals</span><span class='lparen'>(</span><span class='int'>2</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='int'>2</span><span class='rparen'>)</span>
<span class='comment'># no error raised</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter does not equal expected parameter.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_equals'>equals</span><span class='lparen'>(</span><span class='int'>2</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='int'>3</span><span class='rparen'>)</span>
<span class='comment'># error raised, because method_1 was not called with an +Object+ that equals 2</span></code></pre>
    
  </div>
<p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>value</span>
      
      
        <span class='type'>(<tt><span class='object_link'>Object</span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>expected value.</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="Equals.html" title="Mocha::ParameterMatchers::Equals (class)">Equals</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>parameter matcher.</p>
</div>
      
    </li>
  
</ul>

  <p class="tag_title">See Also:</p>
  <ul class="see">
    
      <li><span class='object_link'><a href="../Expectation.html#with-instance_method" title="Mocha::Expectation#with (method)">Expectation#with</a></span></li>
    
      <li>Object#==</li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


27
28
29</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/mocha/parameter_matchers/equals.rb', line 27</span>

<span class='kw'>def</span> <span class='id identifier rubyid_equals'>equals</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
  <span class='const'><span class='object_link'><a href="Equals.html" title="Mocha::ParameterMatchers::Equals (class)">Equals</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="equivalent_uri-instance_method">
  
    #<strong>equivalent_uri</strong>(uri)  &#x21d2; <tt><span class='object_link'><a href="EquivalentUri.html" title="Mocha::ParameterMatchers::EquivalentUri (class)">EquivalentUri</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    
<p>Matches a URI without regard to the ordering of parameters in the query string.</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h4 class="tag_title">Examples:</h4>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual URI is equivalent.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_equivalent_uri'>equivalent_uri</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>http://example.com/foo?a=1&amp;b=2</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>http://example.com/foo?b=2&amp;a=1</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='comment'># no error raised</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual URI is not equivalent.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_equivalent_uri'>equivalent_uri</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>http://example.com/foo?a=1&amp;b=2</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>http://example.com/foo?a=1&amp;b=3</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='comment'># error raised, because the query parameters were different</span></code></pre>
    
  </div>
<p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>uri</span>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>URI to match.</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="EquivalentUri.html" title="Mocha::ParameterMatchers::EquivalentUri (class)">EquivalentUri</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>parameter matcher.</p>
</div>
      
    </li>
  
</ul>

  <p class="tag_title">See Also:</p>
  <ul class="see">
    
      <li><span class='object_link'><a href="../Expectation.html#with-instance_method" title="Mocha::Expectation#with (method)">Expectation#with</a></span></li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


27
28
29</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/mocha/parameter_matchers/equivalent_uri.rb', line 27</span>

<span class='kw'>def</span> <span class='id identifier rubyid_equivalent_uri'>equivalent_uri</span><span class='lparen'>(</span><span class='id identifier rubyid_uri'>uri</span><span class='rparen'>)</span>
  <span class='const'><span class='object_link'><a href="EquivalentUri.html" title="Mocha::ParameterMatchers::EquivalentUri (class)">EquivalentUri</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_uri'>uri</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="has_entries-instance_method">
  
    #<strong>has_entries</strong>(entries)  &#x21d2; <tt><span class='object_link'><a href="HasEntries.html" title="Mocha::ParameterMatchers::HasEntries (class)">HasEntries</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    
<p>Matches <code>Hash</code> containing all <code>entries</code>.</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h4 class="tag_title">Examples:</h4>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter contains all expected entries.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_has_entries'>has_entries</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>key_1</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>1</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>key_2</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>2</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>key_1</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>1</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>key_2</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>2</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>key_3</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>3</span><span class='rparen'>)</span>
<span class='comment'># no error raised</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter does not contain all expected entries.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_has_entries'>has_entries</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>key_1</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>1</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>key_2</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>2</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>key_1</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>1</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>key_2</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>99</span><span class='rparen'>)</span>
<span class='comment'># error raised, because method_1 was not called with Hash containing entries: &#39;key_1&#39; =&gt; 1, &#39;key_2&#39; =&gt; 2</span></code></pre>
    
  </div>
<p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>entries</span>
      
      
        <span class='type'>(<tt>Hash</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>expected <code>Hash</code> entries.</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="HasEntries.html" title="Mocha::ParameterMatchers::HasEntries (class)">HasEntries</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>parameter matcher.</p>
</div>
      
    </li>
  
</ul>

  <p class="tag_title">See Also:</p>
  <ul class="see">
    
      <li><span class='object_link'><a href="../Expectation.html#with-instance_method" title="Mocha::Expectation#with (method)">Expectation#with</a></span></li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


29
30
31</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/mocha/parameter_matchers/has_entries.rb', line 29</span>

<span class='kw'>def</span> <span class='id identifier rubyid_has_entries'>has_entries</span><span class='lparen'>(</span><span class='id identifier rubyid_entries'>entries</span><span class='rparen'>)</span> <span class='comment'># rubocop:disable Naming/PredicatePrefix
</span>  <span class='const'><span class='object_link'><a href="HasEntries.html" title="Mocha::ParameterMatchers::HasEntries (class)">HasEntries</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_entries'>entries</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="has_entry-instance_method">
  
    
      <span class="overload">#<strong>has_entry</strong>(key, value)  &#x21d2; <tt><span class='object_link'><a href="HasEntry.html" title="Mocha::ParameterMatchers::HasEntry (class)">HasEntry</a></span></tt> </span>
    
      <span class="overload">#<strong>has_entry</strong>(single_entry_hash)  &#x21d2; <tt><span class='object_link'><a href="HasEntry.html" title="Mocha::ParameterMatchers::HasEntry (class)">HasEntry</a></span></tt> </span>
    
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    
<p>Matches <code>Hash</code> containing entry with <code>key</code> and <code>value</code>.</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h4 class="tag_title">Examples:</h4>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter contains expected entry supplied as key and value.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_has_entry'>has_entry</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>key_1</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='int'>1</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>key_1</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>1</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>key_2</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>2</span><span class='rparen'>)</span>
<span class='comment'># no error raised</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter contains expected entry supplied as <code>Hash</code> entry.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_has_entry'>has_entry</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>key_1</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>1</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>key_1</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>1</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>key_2</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>2</span><span class='rparen'>)</span>
<span class='comment'># no error raised</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter does not contain expected entry supplied as key and value.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_has_entry'>has_entry</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>key_1</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='int'>1</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>key_1</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>2</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>key_2</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>1</span><span class='rparen'>)</span>
<span class='comment'># error raised, because method_1 was not called with Hash containing entry: &#39;key_1&#39; =&gt; 1</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter does not contain expected entry supplied as <code>Hash</code> entry.</p>
</div></h5>
      
      <pre class="example code"><code>
<span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_has_entry'>has_entry</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>key_1</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>1</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>key_1</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>2</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>key_2</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>1</span><span class='rparen'>)</span>
<span class='comment'># error raised, because method_1 was not called with Hash containing entry: &#39;key_1&#39; =&gt; 1</span></code></pre>
    
  </div>

  <p class="tag_title">Overloads:</p>
  <ul class="overload">
    
      
      <li class="overload_item">
        <span class="signature">#<strong>has_entry</strong>(key, value)  &#x21d2; <tt><span class='object_link'><a href="HasEntry.html" title="Mocha::ParameterMatchers::HasEntry (class)">HasEntry</a></span></tt> </span>
        <div class="docstring">
  <div class="discussion">
    

  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>key</span>
      
      
        <span class='type'>(<tt><span class='object_link'>Object</span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>key for entry.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>value</span>
      
      
        <span class='type'>(<tt><span class='object_link'>Object</span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>value for entry.</p>
</div>
      
    </li>
  
</ul>


</div>
      </li>
    
      
      <li class="overload_item">
        <span class="signature">#<strong>has_entry</strong>(single_entry_hash)  &#x21d2; <tt><span class='object_link'><a href="HasEntry.html" title="Mocha::ParameterMatchers::HasEntry (class)">HasEntry</a></span></tt> </span>
        <div class="docstring">
  <div class="discussion">
    

  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>single_entry_hash</span>
      
      
        <span class='type'>(<tt>Hash</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p><code>Hash</code> with single entry.</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Raises:</p>
<ul class="raise">
  
    <li>
      
      
        <span class='type'>(<tt>ArgumentError</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>if <code>single_entry_hash</code> does not contain exactly one entry.</p>
</div>
      
    </li>
  
</ul>

</div>
      </li>
    
  </ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="HasEntry.html" title="Mocha::ParameterMatchers::HasEntry (class)">HasEntry</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>parameter matcher.</p>
</div>
      
    </li>
  
</ul>

  <p class="tag_title">See Also:</p>
  <ul class="see">
    
      <li><span class='object_link'><a href="../Expectation.html#with-instance_method" title="Mocha::Expectation#with (method)">Expectation#with</a></span></li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


46
47
48
49
50
51
52
53
54
55
56
57
58</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/mocha/parameter_matchers/has_entry.rb', line 46</span>

<span class='kw'>def</span> <span class='id identifier rubyid_has_entry'>has_entry</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span> <span class='comment'># rubocop:disable Naming/PredicatePrefix
</span>  <span class='kw'>case</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span>
  <span class='kw'>when</span> <span class='int'>0</span>
    <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>No arguments. Expecting at least one.</span><span class='tstring_end'>&#39;</span></span>
  <span class='kw'>when</span> <span class='int'>1</span>
    <span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="HasEntry.html" title="Mocha::ParameterMatchers::HasEntry (class)">HasEntry</a></span></span><span class='period'>.</span><span class='id identifier rubyid_parse_option'>parse_option</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='rparen'>)</span>
  <span class='kw'>when</span> <span class='int'>2</span>
    <span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span>
  <span class='kw'>else</span>
    <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Too many arguments; use either a single argument (must be a Hash) or two arguments (a key and a value).</span><span class='tstring_end'>&#39;</span></span>
  <span class='kw'>end</span>
  <span class='const'><span class='object_link'><a href="HasEntry.html" title="Mocha::ParameterMatchers::HasEntry (class)">HasEntry</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="has_key-instance_method">
  
    #<strong>has_key</strong>(key)  &#x21d2; <tt><span class='object_link'><a href="HasKey.html" title="Mocha::ParameterMatchers::HasKey (class)">HasKey</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    
<p>Matches <code>Hash</code> containing <code>key</code>.</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h4 class="tag_title">Examples:</h4>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter contains entry with expected key.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_has_key'>has_key</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>key_1</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>key_1</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>1</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>key_2</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>2</span><span class='rparen'>)</span>
<span class='comment'># no error raised</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter does not contain entry with expected key.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_has_key'>has_key</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>key_1</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>key_2</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>2</span><span class='rparen'>)</span>
<span class='comment'># error raised, because method_1 was not called with Hash containing key: &#39;key_1&#39;</span></code></pre>
    
  </div>
<p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>key</span>
      
      
        <span class='type'>(<tt><span class='object_link'>Object</span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>expected key.</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="HasKey.html" title="Mocha::ParameterMatchers::HasKey (class)">HasKey</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>parameter matcher.</p>
</div>
      
    </li>
  
</ul>

  <p class="tag_title">See Also:</p>
  <ul class="see">
    
      <li><span class='object_link'><a href="../Expectation.html#with-instance_method" title="Mocha::Expectation#with (method)">Expectation#with</a></span></li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


27
28
29</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/mocha/parameter_matchers/has_key.rb', line 27</span>

<span class='kw'>def</span> <span class='id identifier rubyid_has_key'>has_key</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span> <span class='comment'># rubocop:disable Naming/PredicatePrefix
</span>  <span class='const'><span class='object_link'><a href="HasKey.html" title="Mocha::ParameterMatchers::HasKey (class)">HasKey</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="has_keys-instance_method">
  
    #<strong>has_keys</strong>(*keys)  &#x21d2; <tt><span class='object_link'><a href="HasKeys.html" title="Mocha::ParameterMatchers::HasKeys (class)">HasKeys</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    
<p>Matches <code>Hash</code> containing <code>keys</code>.</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h4 class="tag_title">Examples:</h4>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter contains entry with expected keys.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_has_keys'>has_keys</span><span class='lparen'>(</span><span class='symbol'>:key_1</span><span class='comma'>,</span> <span class='symbol'>:key_2</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='symbol'>:key_1</span> <span class='op'>=&gt;</span> <span class='int'>1</span><span class='comma'>,</span> <span class='symbol'>:key_2</span> <span class='op'>=&gt;</span> <span class='int'>2</span><span class='comma'>,</span> <span class='symbol'>:key_3</span> <span class='op'>=&gt;</span> <span class='int'>3</span><span class='rparen'>)</span>
<span class='comment'># no error raised</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter does not contain all expected keys.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_has_keys'>has_keys</span><span class='lparen'>(</span><span class='symbol'>:key_1</span><span class='comma'>,</span> <span class='symbol'>:key_2</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='symbol'>:key_2</span> <span class='op'>=&gt;</span> <span class='int'>2</span><span class='rparen'>)</span>
<span class='comment'># error raised, because method_1 was not called with Hash containing key: :key_1</span></code></pre>
    
  </div>
<p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>keys</span>
      
      
        <span class='type'>(<tt>*Array&lt;<span class='object_link'>Object</span>&gt;</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>expected keys.</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="HasKeys.html" title="Mocha::ParameterMatchers::HasKeys (class)">HasKeys</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>parameter matcher.</p>
</div>
      
    </li>
  
</ul>

  <p class="tag_title">See Also:</p>
  <ul class="see">
    
      <li><span class='object_link'><a href="../Expectation.html#with-instance_method" title="Mocha::Expectation#with (method)">Expectation#with</a></span></li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


27
28
29</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/mocha/parameter_matchers/has_keys.rb', line 27</span>

<span class='kw'>def</span> <span class='id identifier rubyid_has_keys'>has_keys</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_keys'>keys</span><span class='rparen'>)</span> <span class='comment'># rubocop:disable Naming/PredicatePrefix
</span>  <span class='const'><span class='object_link'><a href="HasKeys.html" title="Mocha::ParameterMatchers::HasKeys (class)">HasKeys</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_keys'>keys</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="has_value-instance_method">
  
    #<strong>has_value</strong>(value)  &#x21d2; <tt><span class='object_link'><a href="HasValue.html" title="Mocha::ParameterMatchers::HasValue (class)">HasValue</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    
<p>Matches <code>Hash</code> containing <code>value</code>.</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h4 class="tag_title">Examples:</h4>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter contains entry with expected value.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_has_value'>has_value</span><span class='lparen'>(</span><span class='int'>1</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>key_1</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>1</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>key_2</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>2</span><span class='rparen'>)</span>
<span class='comment'># no error raised</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter does not contain entry with expected value.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_has_value'>has_value</span><span class='lparen'>(</span><span class='int'>1</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>key_2</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>2</span><span class='rparen'>)</span>
<span class='comment'># error raised, because method_1 was not called with Hash containing value: 1</span></code></pre>
    
  </div>
<p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>value</span>
      
      
        <span class='type'>(<tt><span class='object_link'>Object</span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>expected value.</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="HasValue.html" title="Mocha::ParameterMatchers::HasValue (class)">HasValue</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>parameter matcher.</p>
</div>
      
    </li>
  
</ul>

  <p class="tag_title">See Also:</p>
  <ul class="see">
    
      <li><span class='object_link'><a href="../Expectation.html#with-instance_method" title="Mocha::Expectation#with (method)">Expectation#with</a></span></li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


27
28
29</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/mocha/parameter_matchers/has_value.rb', line 27</span>

<span class='kw'>def</span> <span class='id identifier rubyid_has_value'>has_value</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='comment'># rubocop:disable Naming/PredicatePrefix
</span>  <span class='const'><span class='object_link'><a href="HasValue.html" title="Mocha::ParameterMatchers::HasValue (class)">HasValue</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="includes-instance_method">
  
    #<strong>includes</strong>(*items)  &#x21d2; <tt><span class='object_link'><a href="Includes.html" title="Mocha::ParameterMatchers::Includes (class)">Includes</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    
<p>Matches any object that responds with <code>true</code> to <tt>include?(item)</tt> for all items.</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h4 class="tag_title">Examples:</h4>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter includes all items.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_includes'>includes</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>foo</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>bar</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>foo</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>bar</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>baz</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
<span class='comment'># no error raised</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter does not include all items.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>foo</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>baz</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
<span class='comment'># error raised, because [&#39;foo&#39;, &#39;baz&#39;] does not include &#39;bar&#39;.</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter includes item which matches nested matcher.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_includes'>includes</span><span class='lparen'>(</span><span class='id identifier rubyid_has_key'>has_key</span><span class='lparen'>(</span><span class='symbol'>:key</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>foo</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>bar</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='label'>key:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>baz</span><span class='tstring_end'>&#39;</span></span><span class='rbrace'>}</span><span class='rbracket'>]</span><span class='rparen'>)</span>
<span class='comment'># no error raised</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter does not include item matching nested matcher.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>foo</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>bar</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='symbol'>:other_key</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>baz</span><span class='tstring_end'>&#39;</span></span><span class='rbrace'>}</span><span class='rbracket'>]</span><span class='rparen'>)</span>
<span class='comment'># error raised, because no element matches `has_key(:key)` matcher</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter is a String including substring.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_includes'>includes</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>bar</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>foobarbaz</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='comment'># no error raised</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter is a String not including substring.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>foobaz</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='comment'># error raised, because &#39;foobaz&#39; does not include &#39;bar&#39;</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter is a Hash including the given key.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_includes'>includes</span><span class='lparen'>(</span><span class='symbol'>:bar</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='label'>foo:</span> <span class='int'>1</span><span class='comma'>,</span> <span class='label'>bar:</span> <span class='int'>2</span><span class='rbrace'>}</span><span class='rparen'>)</span>
<span class='comment'># no error raised</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter is a Hash without the given key.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='label'>foo:</span> <span class='int'>1</span><span class='comma'>,</span> <span class='label'>baz:</span> <span class='int'>2</span><span class='rbrace'>}</span><span class='rparen'>)</span>
<span class='comment'># error raised, because hash does not include key &#39;bar&#39;</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter is a Hash with a key matching the given matcher.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_includes'>includes</span><span class='lparen'>(</span><span class='id identifier rubyid_regexp_matches'>regexp_matches</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>ar</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>foo</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>1</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>bar</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>2</span><span class='rbrace'>}</span><span class='rparen'>)</span>
<span class='comment'># no error raised</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter is a Hash no key matching the given matcher.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>foo</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>1</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>baz</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='int'>3</span><span class='rbrace'>}</span><span class='rparen'>)</span>
<span class='comment'># error raised, because hash does not include a key matching /ar/</span></code></pre>
    
  </div>
<p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>items</span>
      
      
        <span class='type'>(<tt>*Array</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>expected items.</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="Includes.html" title="Mocha::ParameterMatchers::Includes (class)">Includes</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>parameter matcher.</p>
</div>
      
    </li>
  
</ul>

  <p class="tag_title">See Also:</p>
  <ul class="see">
    
      <li><span class='object_link'><a href="../Expectation.html#with-instance_method" title="Mocha::Expectation#with (method)">Expectation#with</a></span></li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


66
67
68</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/mocha/parameter_matchers/includes.rb', line 66</span>

<span class='kw'>def</span> <span class='id identifier rubyid_includes'>includes</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_items'>items</span><span class='rparen'>)</span>
  <span class='const'><span class='object_link'><a href="Includes.html" title="Mocha::ParameterMatchers::Includes (class)">Includes</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_items'>items</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="instance_of-instance_method">
  
    #<strong>instance_of</strong>(klass)  &#x21d2; <tt><span class='object_link'><a href="InstanceOf.html" title="Mocha::ParameterMatchers::InstanceOf (class)">InstanceOf</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    
<p>Matches any object that is an instance of <code>klass</code></p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h4 class="tag_title">Examples:</h4>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter is an instance of <code>String</code>.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_instance_of'>instance_of</span><span class='lparen'>(</span><span class='const'>String</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>string</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='comment'># no error raised</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter is not an instance of <code>String</code>.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_instance_of'>instance_of</span><span class='lparen'>(</span><span class='const'>String</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='int'>99</span><span class='rparen'>)</span>
<span class='comment'># error raised, because method_1 was not called with an instance of String</span></code></pre>
    
  </div>
<p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>klass</span>
      
      
        <span class='type'>(<tt>Class</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>expected class.</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="InstanceOf.html" title="Mocha::ParameterMatchers::InstanceOf (class)">InstanceOf</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>parameter matcher.</p>
</div>
      
    </li>
  
</ul>

  <p class="tag_title">See Also:</p>
  <ul class="see">
    
      <li><span class='object_link'><a href="../Expectation.html#with-instance_method" title="Mocha::Expectation#with (method)">Expectation#with</a></span></li>
    
      <li>Kernel#instance_of?</li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


27
28
29</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/mocha/parameter_matchers/instance_of.rb', line 27</span>

<span class='kw'>def</span> <span class='id identifier rubyid_instance_of'>instance_of</span><span class='lparen'>(</span><span class='id identifier rubyid_klass'>klass</span><span class='rparen'>)</span>
  <span class='const'><span class='object_link'><a href="InstanceOf.html" title="Mocha::ParameterMatchers::InstanceOf (class)">InstanceOf</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_klass'>klass</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="is_a-instance_method">
  
    #<strong>is_a</strong>(klass)  &#x21d2; <tt><span class='object_link'><a href="IsA.html" title="Mocha::ParameterMatchers::IsA (class)">IsA</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    
<p>Matches any object that is a <code>klass</code>.</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h4 class="tag_title">Examples:</h4>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter is a <code>Integer</code>.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_is_a'>is_a</span><span class='lparen'>(</span><span class='const'>Integer</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='int'>99</span><span class='rparen'>)</span>
<span class='comment'># no error raised</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter is not a <code>Integer</code>.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_is_a'>is_a</span><span class='lparen'>(</span><span class='const'>Integer</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>string</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='comment'># error raised, because method_1 was not called with an Integer</span></code></pre>
    
  </div>
<p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>klass</span>
      
      
        <span class='type'>(<tt>Class</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>expected class.</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="IsA.html" title="Mocha::ParameterMatchers::IsA (class)">IsA</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>parameter matcher.</p>
</div>
      
    </li>
  
</ul>

  <p class="tag_title">See Also:</p>
  <ul class="see">
    
      <li><span class='object_link'><a href="../Expectation.html#with-instance_method" title="Mocha::Expectation#with (method)">Expectation#with</a></span></li>
    
      <li>Kernel#is_a?</li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


28
29
30</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/mocha/parameter_matchers/is_a.rb', line 28</span>

<span class='kw'>def</span> <span class='id identifier rubyid_is_a'>is_a</span><span class='lparen'>(</span><span class='id identifier rubyid_klass'>klass</span><span class='rparen'>)</span> <span class='comment'># rubocop:disable Naming/PredicatePrefix
</span>  <span class='const'><span class='object_link'><a href="IsA.html" title="Mocha::ParameterMatchers::IsA (class)">IsA</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_klass'>klass</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="kind_of-instance_method">
  
    #<strong>kind_of</strong>(klass)  &#x21d2; <tt><span class='object_link'><a href="KindOf.html" title="Mocha::ParameterMatchers::KindOf (class)">KindOf</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    
<p>Matches any <code>Object</code> that is a kind of <code>klass</code>.</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h4 class="tag_title">Examples:</h4>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter is a kind of <code>Integer</code>.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_kind_of'>kind_of</span><span class='lparen'>(</span><span class='const'>Integer</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='int'>99</span><span class='rparen'>)</span>
<span class='comment'># no error raised</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter is not a kind of <code>Integer</code>.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_kind_of'>kind_of</span><span class='lparen'>(</span><span class='const'>Integer</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>string</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='comment'># error raised, because method_1 was not called with a kind of Integer</span></code></pre>
    
  </div>
<p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>klass</span>
      
      
        <span class='type'>(<tt>Class</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>expected class.</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="KindOf.html" title="Mocha::ParameterMatchers::KindOf (class)">KindOf</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>parameter matcher.</p>
</div>
      
    </li>
  
</ul>

  <p class="tag_title">See Also:</p>
  <ul class="see">
    
      <li><span class='object_link'><a href="../Expectation.html#with-instance_method" title="Mocha::Expectation#with (method)">Expectation#with</a></span></li>
    
      <li>Kernel#kind_of?</li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


27
28
29</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/mocha/parameter_matchers/kind_of.rb', line 27</span>

<span class='kw'>def</span> <span class='id identifier rubyid_kind_of'>kind_of</span><span class='lparen'>(</span><span class='id identifier rubyid_klass'>klass</span><span class='rparen'>)</span>
  <span class='const'><span class='object_link'><a href="KindOf.html" title="Mocha::ParameterMatchers::KindOf (class)">KindOf</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_klass'>klass</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="Not-instance_method">
  
    #<strong>Not</strong>(matcher)  &#x21d2; <tt><span class='object_link'><a href="#Not-instance_method" title="Mocha::ParameterMatchers::Methods#Not (method)">Not</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    
<p>Matches if <code>matcher</code> does <strong>not</strong> match.</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h4 class="tag_title">Examples:</h4>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter does not include the value <code>1</code>.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='const'>Not</span><span class='lparen'>(</span><span class='id identifier rubyid_includes'>includes</span><span class='lparen'>(</span><span class='int'>1</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>2</span><span class='comma'>,</span> <span class='int'>3</span><span class='rbracket'>]</span><span class='rparen'>)</span>
<span class='comment'># no error raised</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter does include the value <code>1</code>.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='const'>Not</span><span class='lparen'>(</span><span class='id identifier rubyid_includes'>includes</span><span class='lparen'>(</span><span class='int'>1</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='comma'>,</span> <span class='int'>2</span><span class='comma'>,</span> <span class='int'>3</span><span class='rbracket'>]</span><span class='rparen'>)</span>
<span class='comment'># error raised, because method_1 was not called with object not including 1</span></code></pre>
    
  </div>
<p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>matcher</span>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="BaseMethods.html" title="Mocha::ParameterMatchers::BaseMethods (module)">BaseMethods</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>matcher whose logic to invert.</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="#Not-instance_method" title="Mocha::ParameterMatchers::Methods#Not (method)">Not</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>parameter matcher.</p>
</div>
      
    </li>
  
</ul>

  <p class="tag_title">See Also:</p>
  <ul class="see">
    
      <li><span class='object_link'><a href="../Expectation.html#with-instance_method" title="Mocha::Expectation#with (method)">Expectation#with</a></span></li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


27
28
29</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/mocha/parameter_matchers/not.rb', line 27</span>

<span class='kw'>def</span> <span class='const'>Not</span><span class='lparen'>(</span><span class='id identifier rubyid_matcher'>matcher</span><span class='rparen'>)</span> <span class='comment'># rubocop:disable Naming/MethodName
</span>  <span class='const'>Not</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_matcher'>matcher</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="optionally-instance_method">
  
    #<strong>optionally</strong>(*matchers)  &#x21d2; <tt><span class='object_link'><a href="Optionally.html" title="Mocha::ParameterMatchers::Optionally (class)">Optionally</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    
<p>Matches optional parameters if available.</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h4 class="tag_title">Examples:</h4>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Only the two required parameters are supplied and they both match their expected value.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='int'>1</span><span class='comma'>,</span> <span class='int'>2</span><span class='comma'>,</span> <span class='id identifier rubyid_optionally'>optionally</span><span class='lparen'>(</span><span class='int'>3</span><span class='comma'>,</span> <span class='int'>4</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='int'>1</span><span class='comma'>,</span> <span class='int'>2</span><span class='rparen'>)</span>
<span class='comment'># no error raised</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Both required parameters and one of the optional parameters are supplied and they all match their expected value.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='int'>1</span><span class='comma'>,</span> <span class='int'>2</span><span class='comma'>,</span> <span class='id identifier rubyid_optionally'>optionally</span><span class='lparen'>(</span><span class='int'>3</span><span class='comma'>,</span> <span class='int'>4</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='int'>1</span><span class='comma'>,</span> <span class='int'>2</span><span class='comma'>,</span> <span class='int'>3</span><span class='rparen'>)</span>
<span class='comment'># no error raised</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Both required parameters and both of the optional parameters are supplied and they all match their expected value.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='int'>1</span><span class='comma'>,</span> <span class='int'>2</span><span class='comma'>,</span> <span class='id identifier rubyid_optionally'>optionally</span><span class='lparen'>(</span><span class='int'>3</span><span class='comma'>,</span> <span class='int'>4</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='int'>1</span><span class='comma'>,</span> <span class='int'>2</span><span class='comma'>,</span> <span class='int'>3</span><span class='comma'>,</span> <span class='int'>4</span><span class='rparen'>)</span>
<span class='comment'># no error raised</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>One of the actual optional parameters does not match the expected value.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='int'>1</span><span class='comma'>,</span> <span class='int'>2</span><span class='comma'>,</span> <span class='id identifier rubyid_optionally'>optionally</span><span class='lparen'>(</span><span class='int'>3</span><span class='comma'>,</span> <span class='int'>4</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='int'>1</span><span class='comma'>,</span> <span class='int'>2</span><span class='comma'>,</span> <span class='int'>3</span><span class='comma'>,</span> <span class='int'>5</span><span class='rparen'>)</span>
<span class='comment'># error raised, because optional parameters did not match</span></code></pre>
    
  </div>
<p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>matchers</span>
      
      
        <span class='type'>(<tt>*Array&lt;<span class='object_link'><a href="BaseMethods.html" title="Mocha::ParameterMatchers::BaseMethods (module)">BaseMethods</a></span>&gt;</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>matchers for optional parameters.</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="Optionally.html" title="Mocha::ParameterMatchers::Optionally (class)">Optionally</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>parameter matcher.</p>
</div>
      
    </li>
  
</ul>

  <p class="tag_title">See Also:</p>
  <ul class="see">
    
      <li><span class='object_link'><a href="../Expectation.html#with-instance_method" title="Mocha::Expectation#with (method)">Expectation#with</a></span></li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


36
37
38</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/mocha/parameter_matchers/optionally.rb', line 36</span>

<span class='kw'>def</span> <span class='id identifier rubyid_optionally'>optionally</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_matchers'>matchers</span><span class='rparen'>)</span>
  <span class='const'><span class='object_link'><a href="Optionally.html" title="Mocha::ParameterMatchers::Optionally (class)">Optionally</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_matchers'>matchers</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="regexp_matches-instance_method">
  
    #<strong>regexp_matches</strong>(regexp)  &#x21d2; <tt><span class='object_link'><a href="RegexpMatches.html" title="Mocha::ParameterMatchers::RegexpMatches (class)">RegexpMatches</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    
<p>Matches any object that matches <code>regexp</code>.</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h4 class="tag_title">Examples:</h4>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter is matched by specified regular expression.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_regexp_matches'>regexp_matches</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>e</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>hello</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='comment'># no error raised</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter is not matched by specified regular expression.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_regexp_matches'>regexp_matches</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>a</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>hello</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='comment'># error raised, because method_1 was not called with a parameter that matched the
</span><span class='comment'># regular expression</span></code></pre>
    
  </div>
<p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>regexp</span>
      
      
        <span class='type'>(<tt>Regexp</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>regular expression to match.</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="RegexpMatches.html" title="Mocha::ParameterMatchers::RegexpMatches (class)">RegexpMatches</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>parameter matcher.</p>
</div>
      
    </li>
  
</ul>

  <p class="tag_title">See Also:</p>
  <ul class="see">
    
      <li><span class='object_link'><a href="../Expectation.html#with-instance_method" title="Mocha::Expectation#with (method)">Expectation#with</a></span></li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


27
28
29</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/mocha/parameter_matchers/regexp_matches.rb', line 27</span>

<span class='kw'>def</span> <span class='id identifier rubyid_regexp_matches'>regexp_matches</span><span class='lparen'>(</span><span class='id identifier rubyid_regexp'>regexp</span><span class='rparen'>)</span>
  <span class='const'><span class='object_link'><a href="RegexpMatches.html" title="Mocha::ParameterMatchers::RegexpMatches (class)">RegexpMatches</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_regexp'>regexp</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="responds_with-instance_method">
  
    
      <span class="overload">#<strong>responds_with</strong>(message, result)  &#x21d2; <tt><span class='object_link'><a href="RespondsWith.html" title="Mocha::ParameterMatchers::RespondsWith (class)">RespondsWith</a></span></tt> </span>
    
      <span class="overload">#<strong>responds_with</strong>(messages_vs_results)  &#x21d2; <tt><span class='object_link'><a href="RespondsWith.html" title="Mocha::ParameterMatchers::RespondsWith (class)">RespondsWith</a></span></tt> </span>
    
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    
<p>Returns parameter matcher.</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h4 class="tag_title">Examples:</h4>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter responds with “FOO” when :upcase is invoked.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_responds_with'>responds_with</span><span class='lparen'>(</span><span class='symbol'>:upcase</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>FOO</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>foo</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='comment'># no error raised, because &quot;foo&quot;.upcase == &quot;FOO&quot;</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter does not respond with “FOO” when :upcase is invoked.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_responds_with'>responds_with</span><span class='lparen'>(</span><span class='symbol'>:upcase</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>BAR</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>foo</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='comment'># error raised, because &quot;foo&quot;.upcase != &quot;BAR&quot;</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter responds with “FOO” when :upcase is invoked and “oof” when :reverse is invoked.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_responds_with'>responds_with</span><span class='lparen'>(</span><span class='label'>upcase:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>FOO</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>reverse:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>oof</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>foo</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='comment'># no error raised, because &quot;foo&quot;.upcase == &quot;FOO&quot; and &quot;foo&quot;.reverse == &quot;oof&quot;</span></code></pre>
    
  </div>

  <p class="tag_title">Overloads:</p>
  <ul class="overload">
    
      
      <li class="overload_item">
        <span class="signature">#<strong>responds_with</strong>(message, result)  &#x21d2; <tt><span class='object_link'><a href="RespondsWith.html" title="Mocha::ParameterMatchers::RespondsWith (class)">RespondsWith</a></span></tt> </span>
        <div class="docstring">
  <div class="discussion">
    
<p>Matches any object that responds to <code>message</code> with <code>result</code>. To put it another way, it tests the quack, not the duck.</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>message</span>
      
      
        <span class='type'>(<tt>Symbol</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>method to invoke.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>result</span>
      
      
        <span class='type'>(<tt><span class='object_link'>Object</span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>expected result of sending <code>message</code>.</p>
</div>
      
    </li>
  
</ul>


</div>
      </li>
    
      
      <li class="overload_item">
        <span class="signature">#<strong>responds_with</strong>(messages_vs_results)  &#x21d2; <tt><span class='object_link'><a href="RespondsWith.html" title="Mocha::ParameterMatchers::RespondsWith (class)">RespondsWith</a></span></tt> </span>
        <div class="docstring">
  <div class="discussion">
    
<p>Matches any object that responds to all the messages with the corresponding results as specified by <code>messages_vs_results</code>.</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>messages_vs_results</span>
      
      
        <span class='type'>(<tt>Hash&lt;Symbol,<span class='object_link'>Object</span>&gt;</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p><code>Hash</code> of messages vs results.</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Raises:</p>
<ul class="raise">
  
    <li>
      
      
        <span class='type'>(<tt>ArgumentError</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>if <code>messages_vs_results</code> does not contain at least one entry.</p>
</div>
      
    </li>
  
</ul>

</div>
      </li>
    
  </ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="RespondsWith.html" title="Mocha::ParameterMatchers::RespondsWith (class)">RespondsWith</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>parameter matcher.</p>
</div>
      
    </li>
  
</ul>

  <p class="tag_title">See Also:</p>
  <ul class="see">
    
      <li><span class='object_link'><a href="../Expectation.html#with-instance_method" title="Mocha::Expectation#with (method)">Expectation#with</a></span></li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/mocha/parameter_matchers/responds_with.rb', line 40</span>

<span class='kw'>def</span> <span class='id identifier rubyid_responds_with'>responds_with</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
  <span class='kw'>case</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span>
  <span class='kw'>when</span> <span class='int'>0</span>
    <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>No arguments. Expecting at least one.</span><span class='tstring_end'>&#39;</span></span>
  <span class='kw'>when</span> <span class='int'>1</span>
    <span class='id identifier rubyid_option'>option</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
    <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Argument is not a Hash.</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_option'>option</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Hash</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Argument has no entries.</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_option'>option</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>

    <span class='id identifier rubyid_matchers'>matchers</span> <span class='op'>=</span> <span class='id identifier rubyid_option'>option</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_message'>message</span><span class='comma'>,</span> <span class='id identifier rubyid_result'>result</span><span class='op'>|</span> <span class='const'><span class='object_link'><a href="RespondsWith.html" title="Mocha::ParameterMatchers::RespondsWith (class)">RespondsWith</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_message'>message</span><span class='comma'>,</span> <span class='id identifier rubyid_result'>result</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
    <span class='const'><span class='object_link'><a href="AllOf.html" title="Mocha::ParameterMatchers::AllOf (class)">AllOf</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_matchers'>matchers</span><span class='rparen'>)</span>
  <span class='kw'>when</span> <span class='int'>2</span>
    <span class='id identifier rubyid_message'>message</span><span class='comma'>,</span> <span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span>
    <span class='const'><span class='object_link'><a href="RespondsWith.html" title="Mocha::ParameterMatchers::RespondsWith (class)">RespondsWith</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_message'>message</span><span class='comma'>,</span> <span class='id identifier rubyid_result'>result</span><span class='rparen'>)</span>
  <span class='kw'>else</span>
    <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Too many arguments; use either a single argument (must be a Hash) or two arguments (a message and a result).</span><span class='tstring_end'>&#39;</span></span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="yaml_equivalent-instance_method">
  
    #<strong>yaml_equivalent</strong>(object)  &#x21d2; <tt><span class='object_link'><a href="YamlEquivalent.html" title="Mocha::ParameterMatchers::YamlEquivalent (class)">YamlEquivalent</a></span></tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    
<p>Matches any YAML that represents the specified <code>object</code></p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h4 class="tag_title">Examples:</h4>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter is YAML equivalent of specified <code>object</code>.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_yaml_equivalent'>yaml_equivalent</span><span class='lparen'>(</span><span class='int'>1</span><span class='comma'>,</span> <span class='int'>2</span><span class='comma'>,</span> <span class='int'>3</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>--- \n- 1\n- 2\n- 3\n</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='comment'># no error raised</span></code></pre>
    
      
        <h5 class="example_title"><div class='inline'>
<p>Actual parameter is not YAML equivalent of specified <code>object</code>.</p>
</div></h5>
      
      <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:method_1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='id identifier rubyid_yaml_equivalent'>yaml_equivalent</span><span class='lparen'>(</span><span class='int'>1</span><span class='comma'>,</span> <span class='int'>2</span><span class='comma'>,</span> <span class='int'>3</span><span class='rparen'>)</span><span class='rparen'>)</span>
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_method_1'>method_1</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>--- \n- 1\n- 2\n</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
<span class='comment'># error raised, because method_1 was not called with YAML representing the specified Array</span></code></pre>
    
  </div>
<p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>object</span>
      
      
        <span class='type'>(<tt><span class='object_link'>Object</span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>object whose YAML to compare.</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="YamlEquivalent.html" title="Mocha::ParameterMatchers::YamlEquivalent (class)">YamlEquivalent</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>
<p>parameter matcher.</p>
</div>
      
    </li>
  
</ul>

  <p class="tag_title">See Also:</p>
  <ul class="see">
    
      <li><span class='object_link'><a href="../Expectation.html#with-instance_method" title="Mocha::Expectation#with (method)">Expectation#with</a></span></li>
    
  </ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


27
28
29</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/mocha/parameter_matchers/yaml_equivalent.rb', line 27</span>

<span class='kw'>def</span> <span class='id identifier rubyid_yaml_equivalent'>yaml_equivalent</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span>
  <span class='const'><span class='object_link'><a href="YamlEquivalent.html" title="Mocha::ParameterMatchers::YamlEquivalent (class)">YamlEquivalent</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>

      <div id="footer">
  Generated on Tue Nov 11 14:27:03 2025 by
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
  0.9.37 (ruby-3.3.0).
</div>

    </div>
  </body>
</html>